package springboot.test15.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import springboot.test15.bean.User;
import springboot.test15.sevice.AccountService;


@Slf4j
@RestController
public class testSQL {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @GetMapping("/sql")
    public String queryFromDatabase(){
        Long a = jdbcTemplate.queryForObject("select count(*) from user",Long.class);
        return a.toString();
    }
    @Autowired
    AccountService accountService;

    @GetMapping("/getUsername")
    public User getByName(@RequestParam("username") String username){
        return accountService.getByName(username);
    }



}
